package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type WavepayInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// wavepay--获取一条记录
func NewWavepayInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WavepayInfoLogic {
	return &WavepayInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *WavepayInfoLogic) WavepayInfo(req *types.WavepayInfoRequest) (resp *types.WavepayInfoResponse, err error) {
	rpcReq := rpc.WavepayInfoRequest{
		Id: req.Id,
	}

	rpcResp, err := l.svcCtx.AssetsRpc.TenantChannel.WavepayInfo(l.ctx, &rpcReq)
	if err != nil {
		return nil, err
	}

	return &types.WavepayInfoResponse{
		Wavepay: types.Wavepay{
			Id:           rpcResp.Id,
			CreatedAt:    rpcResp.CreatedAt,
			UpdatedAt:    rpcResp.UpdatedAt,
			Code:         rpcResp.Code,
			Phone:        rpcResp.Phone,
			CardHolder:   rpcResp.CardHolder,
			MinAmount:    rpcResp.MinAmount,
			MaxAmount:    rpcResp.MaxAmount,
			DailyTimes:   rpcResp.DailyTimes,
			DailyAmount:  rpcResp.DailyAmount,
			RemainTimes:  rpcResp.RemainTimes,
			RemainAmount: rpcResp.RemainAmount,
			VisionLevel:  rpcResp.VisionLevel,
			IsDisplay:    rpcResp.IsDisplay,
		},
		CommonResp: types.CommonResp{
			Code:    rpcResp.CommonResp.Code,
			Message: rpcResp.CommonResp.Message,
		},
	}, nil
}
